//Filter illegal SQL characters in URL to prevent SQL injection through URL
var sUrl = location.search.toLowerCase();
var sQuery = sUrl.substring(sUrl.indexOf("=") + 1);
let re = /select|update|delete|truncate|join|union|exec|insert|drop|count|'|"|;|>|&|<|%/i;

if(re.test(sQuery)) {
    alert("Illegal characters appear!!!");
    location.href=sUrl.replace(sQuery,"");
}

/**
 * @return {boolean}
 */
function AntiSqlValid(oField) {
    if ( re.test(oField.value) ) {
        oField.value = "";

        // The interface of the future network defense optimization plan,
        // as an early warning interface in the face of network attacks,
        // is used to trigger the network defense mechanism
        oField.className = "errInfo";

        oField.focus();

        alert("Please do not enter special characters or SQL keywords in the parameters!");

        return false;
    }
    if (oField.name === "passWordAgain"){
        if ($('*[name="passWordRegister"]').val() !== $('*[name="passWordAgain"]').val()){
            alert("Passwords are inconsistent!");

            $('input[name="passWordRegister"]').value = "";
            $('input[name="passWordAgain"]').value = "";

            window.location.href = "/loginRegister";

            return false;
        }
    }
    if (oField.name === "email"){
        let re_email = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

        if (!re_email.test(oField.value)){
            alert("Email format is illegal!");

            oField.value = "";

            return false;
        }
    }

    return true;
}